//
//  MCGuaJiViewController.m
//  ZXZX
//
//  Created by menhao on 2018/8/17.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCGuaJiViewController.h"
#import <WebKit/WebKit.h>



@interface MCGuaJiViewController ()<UIWebViewDelegate>

@property (nonatomic,weak) UIWebView *web;

@end

@implementation MCGuaJiViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    CGFloat h = kStatusBarAndNavigationBarHeight;
    if (IS_iPhoneX) {
        h= h - 35;
    }
    self.navigationItem.title = @"挂机软件";
    self.automaticallyAdjustsScrollViewInsets = NO;
    if (self.navigationController == nil) {
        UILabel *naviBar = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, G_SCREENWIDTH, 20)];
        [self.view addSubview:naviBar];
        UILabel *naviBarContent = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, G_SCREENWIDTH, 44 + kStatusBarAndNavigationBarHeightDifference)];
        [self.view addSubview:naviBarContent];
        naviBarContent.backgroundColor = MC_THEME_COLOR;
        naviBar.backgroundColor = MC_THEME_COLOR;
        naviBarContent.text = @"挂机软件";
        naviBarContent.textAlignment = NSTextAlignmentCenter;
        naviBarContent.textColor = [UIColor whiteColor];
        naviBarContent.font = [UIFont systemFontOfSize:MC_REALVALUE(16)];
        
        UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectMake(0, kStatusBarAndNavigationBarHeight, G_SCREENWIDTH, G_SCREENHEIGHT - h)];
        web.delegate = self;
        [self.view addSubview:web];
        self.web = web;
        UIButton *btn = [[UIButton alloc] init];
        btn.frame = CGRectMake(20, 20, 30, 30);
        [btn setBackgroundImage:[UIImage imageNamed:@"图层-6"] forState:UIControlStateNormal];
        [self.view addSubview:btn];
        [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
        if ([self.title isEqualToString:@"挂机软件"]) {
            btn.hidden = YES;
        } else {
            btn.hidden = NO;
        }
    }
    
    [self.web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.cw.pub/app.php/563"]]];
    

    
    
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
    [BKIndicationView showInView:self.view];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [BKIndicationView dismiss];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    if (error.code == -1001 ||error.code == 4) {
        
        [BKIndicationView dismiss];
        [SVProgressHUD showInfoWithStatus:@"页面加载超时！"];
    } else {
        [SVProgressHUD showInfoWithStatus:@"页面无法加载！"];
        [BKIndicationView dismiss];
    }
}


- (void)btnClick{
    [self dismissViewControllerAnimated:YES completion:nil];
}


@end

